fix(shared): avoid false offline detection in React Native#8084
fix(shared): avoid false offline detection in React Native#8084brkalow merged 6 commits intoclerk:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 3adcdb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@eliotgevers is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughisBrowserOnline was updated to return true when 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.Add a .trivyignore file to your project to customize which findings Trivy reports. |
chriscanin
left a comment
There was a problem hiding this comment.
Tested and looking good. Setting this to approved.
Clerk's isBrowserOnline() treats undefined navigator.onLine (React Native) as offline, causing clerk_offline errors on every getToken call. Patch @clerk/shared to treat unknown onLine as online, matching the upstream fix in clerk/javascript#8084. Remove when upgrading to a @clerk/shared version that includes the fix. Also fix the backup nudge showing when the backup status query fails by removing the catch-all that returned "not configured" on network errors, and gating the nudge on backupStatusLoaded so it only fires once we have a definitive answer from the server. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
This fixes false offline detection in React Native / Expo when
navigator.onLineis not implemented.session.getToken({ skipCache: true })goes through the forced-refresh path, which checks the shared online helper before fetching a fresh token. In React Native,windowandnavigatorexist, butnavigator.onLinedoes not, so the current logic treats the runtime as offline and throwsClerkOfflineError.This change treats React Native, and runtimes without a boolean
navigator.onLine, as online/unknown rather than offline. Actual network failures still surface through the normal fetch path.Changes
truefromisBrowserOnline()for React Nativetruewhennavigator.onLineis not implemented as a boolean@clerk/sharedValidation
pnpm --filter @clerk/shared test -- src/__tests__/browser.spec.tsFixes #8083
Summary by CodeRabbit
Bug Fixes
Tests